<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.5, maximum-scale=0.5,minimum-scale=0.5,user-scalable=0" />
    <title>注册与登录的弹窗Popup</title>
    <style>
        .popup-container {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .popup {
            /* display: none; */
            background-color: #fff;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border-radius: 5px;
            padding: 80px;
            width: 500px;
            box-sizing: border-box;
            position: relative;
            margin-right: 20px;
        }

        .popup-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .popup-header h2 {
            margin: 0;
            margin-bottom: 40px;
        }

        .close {
            cursor: pointer;
            position: absolute;
            right: 10px;
            top:5px;
            font-size: 26px;
            color: #ccc;
        }

        .popup-body input {
            width: 100%;
            margin-bottom: 20px;
            padding: 8px;
            border: 1px solid #eee;
            border-radius: 3px;
        }

        .popup-body button {
            width: 100%;
            padding:15px 10px;
            margin-top: 10px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

        .popup-footer p {
            margin: 10px 0 0;
        }

        .popup-footer a {
            color: #007bff;
            text-decoration: none;
        }
    </style>
</head>

<body>
    <div class="popup-container">
        <div class="popup">
            <div class="popup-header">
                <h2>登录</h2>
                <span class="close">&times;</span>
            </div>
            <div class="popup-body">
                <form id="loginForm">
                    <input type="text" name="username" placeholder="请输入用户名" required>
                    <input type="password" name="password" placeholder="请输入密码" required>
                    <button type="submit">登录</button>
                </form>
            </div>
            <div class="popup-footer">
                <p>没有账号? <a href="#" class="register-link">注册</a></p>
            </div>
        </div>

        <div class="popup">
            <div class="popup-header">
                <h2>注册</h2>
                <span class="close">&times;</span>
            </div>
            <div class="popup-body">
                <form id="registerForm">
                    <input type="text" name="username" placeholder="请输入用户名" required>
                    <input type="password" name="password" placeholder="请输入密码" required>
                    <button type="submit">注册</button>
                </form>
            </div>
            <div class="popup-footer">
                <p>已经有账号了? <a href="#" class="login-link">登录</a></p>
            </div>
        </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function () {
            // 显示登录弹窗
            $('.login-link').click(function (e) {
                e.preventDefault();
                $('.popup').hide();
                $('#loginPopup').show();
            });

            // 显示注册弹窗
            $('.register-link').click(function (e) {
                e.preventDefault();
                $('.popup').hide();
                $('#registerPopup').show();
            });

            // 关闭弹窗
            $('.close').click(function () {
                $(this).closest('.popup').hide();
            });

            // 处理登录表单提交
            $('#loginForm').submit(function (e) {
                e.preventDefault();
                // 在这里添加登录逻辑
                console.log('Login form submitted');
            });

            // 处理注册表单提交
            $('#registerForm').submit(function (e) {
                e.preventDefault();
                // 在这里添加注册逻辑
                console.log('Register form submitted');
            });
        });
    </script>
</body>

</html>